package hiho.ku._1186;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		List<Integer> a = new ArrayList<Integer>();
		for (int i = 1; i <= n; i++)
			if (n % i == 0)
				a.add(i);
		List<Integer> b = new ArrayList<Integer>();
		for (int i = 1; i <= m; i++)
			if (m % i == 0)
				b.add(i);
		for (int i = 0; i < a.size(); i++)
			for (int j = 0; j < b.size(); j++)
				System.out.println(a.get(i) + " " + b.get(j));
	}

}
